home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: Pure virtual destructors?
- Date: Fri, 19 Apr 1996 04:24:48 GMT
- Organization: Netcom
- Message-ID: <3177148b.107663632@nntp.ix.netcom.com>
- References: <4kuq0i$p6t@ftp.ee.vill.edu> <3175BDF5.5ADC81B5@eiffel.com>
- NNTP-Posting-Host: ix-dc13-16.ix.netcom.com
- X-NETCOM-Date: Thu Apr 18 9:25:03 PM PDT 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- "Guus Leeuw jr." <guusl@eiffel.com> wrote:
-
- > sheridan@monet.vill.edu wrote:
- > >
- > > The rule with destructors is that they are always overridden, right?
- > > That's a quote from VC4 docs, BTW. When I do this:
- > >
- > > class CBase {
- > > public:
- > > virtual ~CBase() = 0;
- > > ...};
- > >
- > > class CChild : public CBase {
- > > public:
- > > ~CChild();
- > > ...};
- > >
- > > and declare a body for ~CChild, I always get unresolved external on
- > > CBase::~CBase. I have seen this in several cases. My guess is it's not
- > > a compiler bug, so what am I missing?
- >
- > Here is what the working paper of the ANSI comittee on destructors says (sec.
- > 12.4.6):
- > "Destructors are not inherited. A destructor can be declared virtual or pure
- > virtual; if any objects of that class or any derived class are created in the
- > program, the destructor shall be defined. If a class has a base class with a
- > virtual destructor, its destructor (whether user- or implicitly-declared) is
- > virtual."
- >
- > Which means: You cannot have a pure virual destructor in CBase. It can be
- > virtual, though, for a virtual destructor still comes with a definition.
-
- Huh? You quote the standard as saying that you can have a pure
- virtual destructor and use that for justification for your claim that
- you cannot have a pure virtual destructor.
-
- You certainly may have a pure virtual destructor. Unlike other pure
- virtual member functions, a pure virtual destructor must be
- implemented if any instances of a derived class are created. For
- other pure virtual functions the implementation is not required by the
- language (it may, of course, be needed by the semantics of the class
- being defined).
-
- Michael M Rubenstein
-